package com.example.wan1.data;


import com.example.wan1.model.ArticleBean;
import com.example.wan1.model.BannerBean;
import com.example.wan1.model.CoinBean;
import com.example.wan1.model.CoinSignInBean;
import com.example.wan1.model.CollectArticleBean;
import com.example.wan1.model.CollectWebBean;
import com.example.wan1.model.KnowledgeBean;
import com.example.wan1.model.NaviBean;
import com.example.wan1.model.PersonBean;
import com.example.wan1.model.ProjectCategoryBean;
import com.example.wan1.model.SearchHotBean;
import com.example.wan1.model.TodoBean;
import com.example.wan1.model.WebsiteBean;
import com.example.wan1.model.common.CommonResBody;
import com.example.wan1.model.common.CommonResList;
import com.example.wan1.model.common.CommonResMultiList;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/***
 * 创建时间：2019/12/6 10:30
 * 创建人：10850
 * 功能描述：
 */
public interface ApiService {

    //首页文章列表
    @GET("article/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getArticleList(@Path("page") int age);

    //置顶文章
    @GET("article/top/json")
    Observable<CommonResBody<List<ArticleBean>>> getArticleTopList();

    //首页banner
    @GET("banner/json")
    Observable<CommonResBody<List<BannerBean>>> getBannerList();

    //最新项目
    @GET("article/listproject/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getProjectNewList(@Path("page") int page);

    //项目分类
    @GET("project/tree/json")
    Observable<CommonResBody<List<ProjectCategoryBean>>> getProjectCategory();

    //项目
    @GET("project/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getProjectList(@Path("page") int page, @Query("cid") int cid);

    //广场-----------
    //广场列表 https://wanandroid.com/user_article/list/0/json
    @GET("user_article/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getSquareList(@Path("page") int page);

    //分享人对应列表数据（别人的分享） https://wanandroid.com/user/2/articles/1
    @GET("user/{user}/articles/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getOtherSquareList(@Path("page") int page, @Path("user") int user);


    //体系tree
    @GET("tree/json")
    Observable<CommonResBody<List<KnowledgeBean>>> getKnowledgeTree();

    //知识体系下的文章
    @GET("article/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getPerKnowledgeData(@Path("page") int page,
                                                                              @Query("cid") int cid);

    //公众号列表，标题数据
    @GET("wxarticle/chapters/json")
    Observable<CommonResBody<List<KnowledgeBean>>> getWechatTitleList();

    //公众号列表
    @GET("wxarticle/list/{id}/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getWechatDataList(@Path("id") int id, @Path("page") int page);

    //公众号查询列表
    @GET("wxarticle/list/{id}/{page}/json?k=Java")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getWechatSearchData(@Path("id") int id, @Path("page") int page, @Query("k") String k);

    //开始
    @FormUrlEncoded
    @POST("user/login")
    Observable<CommonResBody<PersonBean>> postLogin(@Field("username") String username, @Field("password") String password);

    @FormUrlEncoded
    @POST("user/register")
    Observable<CommonResBody<PersonBean>> postRegister(@Field("username") String username,
                                                       @Field("password") String password,
                                                       @Field("repassword") String repassword);

    @GET("user/logout/json")
    Observable<CommonResBody> loginOut();

    /*@FormUrlEncoded
    @POST("user/register")
    Observable<CommonResBody<PersonBean>> postRegister(@FieldMap() Map<String, String> registerMap);*/

    //导航数据
    @GET("navi/json")
    Observable<CommonResBody<List<NaviBean>>> getNaviData();

    //常用网站
    @GET("friend/json")
    Observable<CommonResBody<List<WebsiteBean>>> getWebsiteData();

    //问答数据，从1开始
    @GET("wenda/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> getQuestion(@Path("page") int page);

    //收藏站内文章
    @POST("lg/collect/{id}/json")
    Observable<CommonResBody> collectInArticle(@Path("id") int id);

    //收藏站外文章
    @POST("lg/collect/add/json")
    Observable<CommonResBody> collectOutArticle(@Query("title") String title,
                                                @Query("author") String author,
                                                @Query("link") String link);

    //取消收藏（文章列表）
    @POST("lg/uncollect_originId/{id}/json")
    Observable<CommonResBody> cancelCollectArticleList(@Path("id") int id);

    //取消收藏（我的收藏页面）
    @FormUrlEncoded
    @POST("lg/uncollect/{id}/json")
    Observable<CommonResBody> cancelMyCollect(@Path("id") int id, @Field("originId") int originId);

    //收藏文章列表 https://www.wanandroid.com/lg/collect/list/0/json
    @GET("lg/collect/list/{page}/json")
    Observable<CommonResBody<CommonResList<CollectArticleBean>>> getCollectArticleList(@Path("page") int page);

    //收藏网站列表
    @GET("lg/collect/usertools/json")
    Observable<CommonResBody<List<CollectWebBean>>> getCollectWebList();

    //添加网站地址
    @FormUrlEncoded
    @POST("lg/collect/addtool/json")
    Observable<CommonResBody<CollectWebBean>> addCollect(@Field("name") String name, @Field("link") String link);

    //编辑网站地址
    @FormUrlEncoded
    @POST("lg/collect/updatetool/json")
    Observable<CommonResBody<CollectWebBean>> editCollect(@Field("id") int id, @Field("name") String name, @Field("link") String link);

    //删除网站地址
    @FormUrlEncoded
    @POST("lg/collect/deletetool/json")
    Observable<CommonResBody<CollectWebBean>> delCollect(@Field("id") int id);

    //我的分享 https://wanandroid.com/user/lg/private_articles/1/json 从1开始
    @GET("user/lg/private_articles/{page}/json")
    Observable<CommonResBody<CommonResMultiList<CoinBean, CommonResList<ArticleBean>>>> getShareArticleList(@Path("page") int page);

    //删除我的分享文章
    @POST("lg/user_article/delete/{id}/json")
    Observable<CommonResBody<ArticleBean>> delShare(@Path("id") int id);

    //添加我的分享文章
    @FormUrlEncoded
    @POST("lg/user_article/add/json")
    Observable<CommonResBody<ArticleBean>> addShare(@Field("title") String title, @Field("link") String link);

    //文章分享列表 https://www.wanandroid.com/user/2/share_articles/1/json 从1开始
    @GET("user/{id}/share_articles/{page}/json")
    Observable<CommonResBody<CommonResMultiList<CoinBean, CommonResList<ArticleBean>>>> getShareList(
            @Path("id") int id, @Path("page") int page
    );

    //搜索
    //搜索 支持多个关键词，用空格隔开
    @FormUrlEncoded
    @POST("article/query/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> search(@Path("page") int page, @Field("k") String k);

    //知识体系 按照作者昵称搜索文章
    @GET("article/list/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> searchByKnowledge(@Path("page") int page,
                                                                            @Query("author") String author);

    //在某个公众号中搜索历史文章
    @GET("wxarticle/list/{wxId}/{page}/json")
    Observable<CommonResBody<CommonResList<ArticleBean>>> searchByWechat(
            @Path("wxId") int wxId,
            @Path("page") int page, @Query("k") String k);

    //搜索热词
    @GET("hotkey/json")
    Observable<CommonResBody<List<SearchHotBean>>> searchHotData();

    //积分
    //个人积分,从1开始
    //积分排行榜 https://www.wanandroid.com/coin/rank/1/json
    @GET("coin/rank/{page}/json")
    Observable<CommonResBody<CommonResList<CoinBean>>> getCoinRankList(@Path("page") int page);

    //获取个人积分
    @GET("lg/coin/userinfo/json")
    Observable<CommonResBody<CoinBean>> getCoin();

    //个人积分获取列表,从1开始
    @GET("lg/coin/list/{page}/json")
    Observable<CommonResBody<CommonResList<CoinSignInBean>>> getCoinSignInList(@Path("page") int page);

    //to do
    //add to do | priority可选
    @FormUrlEncoded
    @POST("lg/todo/add/json")
    Observable<CommonResBody> addTodo(@Field("title") String title,
                                      @Field("content") String content,
                                      @Field("date") String date,
                                      @Field("type") int type,
                                      @Field("priority") int priority);

    //更新todo(id,title,content必须)
    @FormUrlEncoded
    @POST("lg/todo/update/{id}/json")
    Observable<CommonResBody> updateTodo(@Path("id") int id,
                                         @Field("title") String title,
                                         @Field("content") String content,
                                         @Field("date") String date,
                                         @Field("status") int status,
                                         @Field("type") int type,
                                         @Field("priority") int priority);

    //删除一个Todo
    @POST("lg/todo/delete/{id}/json")
    Observable<CommonResBody> deleteTodo(@Path("id") int id);

    //仅更新完成状态Todo
    @FormUrlEncoded
    @POST("lg/todo/done/{id}/json")
    Observable<CommonResBody> updateTodoStatus(@Path("id") int id, @Field("status") int status);

    //todo列表 从1开始
    @GET("lg/todo/v2/list/{page}/json")
    Observable<CommonResBody<CommonResList<TodoBean>>> todoList(@Path("page") int page,
                                                                @Query("status") int status,
                                                                @Query("type") int type,
                                                                @Query("orderby") int orderby,
                                                                @Query("priority") int priority);

    @GET("lg/todo/v2/list/{page}/json")
    Observable<CommonResBody<CommonResList<TodoBean>>> todoListOrder(@Path("page") int page,
                                                                     @Query("status") int status,
                                                                     @Query("orderby") int orderby);

    @GET("lg/todo/v2/list/{page}/json")
    Observable<CommonResBody<CommonResList<TodoBean>>> todoListOrderAll(@Path("page") int page,
                                                                        @Query("orderby") int orderby);

    @GET("lg/todo/v2/list/{page}/json")
    Observable<CommonResBody<CommonResList<TodoBean>>> todoListAll(@Path("page") int page);
}
